<template>
  <div style="height:287px">
    <a-table class="h-100" :columns="columns" :data-source="list" :pagination="false" rowKey="collegeName" :loading="loading" :scroll="{y: 247}"></a-table>
  </div>
</template>
<script>
export default {
  components: {},
  data() {
    return {
      list: [],
      loading: false,
      columns: [],
    };
  },
  props: {},
  methods: {
    createTable(tableData, typeMap) {
      this.list = tableData;
      for(let i = 0;i < this.list.length;i++){
        for(let j = 0;j < typeMap.length;j++){
          this.list[i][typeMap[j]] = this.list[i]['violationCountMap'][typeMap[j]];
        }
      }
      console.log(this.list);
      this.columns = [
        { title: '学院', dataIndex: 'collegeName', ellipsis: true, width: '22%' },
        { title: '小计', dataIndex: 'total' }
      ];
      typeMap.forEach(item => {
        console.log(this.list);
        this.columns.push(
          {
            title: item,
            dataIndex: item,
            ellipsis: true,
            customRender: text => {
              return text ? text : 0
            }
          }
        )
      });
      // 调换小计和任务数的位置
      this.columns[1] = this.columns[2];
      this.columns[2] = { title: '小计', dataIndex: 'total' };
    },
  },
};
</script>
<style scoped lang="less">
/deep/ .ant-table-tbody > tr > td{
  padding-top: 6px;
  padding-bottom: 6px;
}
/deep/ .ant-spin-container{
  border-bottom: 1px solid #d8dee5;
}
</style>
